Back

JavaScript Practice Questions

  1. You are building a to-do list web app. Write a JavaScript function that allows users to add tasks dynamically to the DOM? Q1
  2. A user is typing in a search input box. Implement a debounce function that waits 500ms before sending the search query? Q2
  3. In an e-commerce site, implement a function to update the shopping cart total when an item is added or removed. Q3
  4. Create a JavaScript object for a 'Library' system. Each book should have title, author, and status. Q4
  5. You're building a quiz app. Write a function to calculate and display the user's score based on correct answers. Q5
  6. Implement an event delegation technique to handle click events on a list of dynamically generated items. Q6
  7. Create a function that tracks the number of times a button is clicked and disables it after 5 clicks. Q7
  8. In a job application form, validate that the phone number is exactly 10 digits and the email is in correct format before submission. Q8
  9. Write a function that periodically fetches updated data from a server every 10 seconds using setInterval. Q9
  10. In a form submission, display a loading spinner while the form is being submitted and remove it once done. Q10